import type { UploadUserFile } from "element-plus"

export interface GetSpuListApiParams {
    page:number
    limit:number
    category3Id:number
}

// 基础销售属性
/*
  [
    {
      id: 1,
      name: xxx
    }
  ]
*/
export interface BaseSaleAttrItem {
    id:number,
    name:string
}
export type BaseSaleAttrList = BaseSaleAttrItem[]

/*
  {
    "spuName": "string",
    "tmId": 0,
    "description": "string",
    "category3Id": 0,
    "spuImageList": [
      {
        "imgName": "string", 
        "imgUrl": "string",
      }
    ],
    "spuSaleAttrList": [
      {
        "baseSaleAttrId": 0, // 基础销售属性id
        "saleAttrName": "string",
        "spuSaleAttrValueList": [ // 销售属性值列表
          {
            "baseSaleAttrId": 0,
            "saleAttrValueName": "string",
          }
        ],
      }
    ],
  }
*/
// 图片
export interface SpuImageItem {
    imgName:string,
    imgUrl:string
}
export type SpuImageList = SpuImageItem[]

// 销售属性值
export interface SpuSaleAttrValueItem {
    baseSaleAttrId:number,
    saleAttrValueName:string,
    id?:number
}
export type SpuSaleAttrValueList = SpuSaleAttrValueItem[]

// 销售属性
export interface SpuSaleAttrItem{
    baseSaleAttrId: number; // 基础销售属性id
    saleAttrName: string;
    spuSaleAttrValueList: SpuSaleAttrValueList;
    isEdit: boolean;
    id?:number
}

export type SpuSaleAttrList = SpuSaleAttrItem[]

export interface Spu{
    id?:number,
    category3Id?:number
    spuName: string;
    tmId: number | undefined;
    description: string;
    spuSaleAttrList: SpuSaleAttrList;
}
export interface SaveSpuItem  extends Spu{
    spuImageList:UploadUserFile[]
}

/*
{
  "records": [
    {
      "id": 6,
      "spuName": "S10 Pro",
      "description": "产品名称\nS10 Pro\n品牌\nvivo\n首销日期\n以官网信息为准\n入网型号\nV2121A\n上市年份\n2021年\n上市月份\n7月",
      // "category3Id": 61,
      // "tmId": 6,
      // "spuSaleAttrList": null,
      // "spuImageList": null,
      // "spuPosterList": null
    }
  ],
  "total": 6,
}
*/

export interface SpuItem extends Spu{
    spuImageList:UploadUserFile[]
}

export type SpuList = SpuItem[]

export interface GetSpuListApiResponse{
    records:SpuList,
    total:number
}
